package com.wxxymaker.edu.model.entity;

import com.blade.kit.StringKit;
import io.github.biezhi.excel.plus.annotation.ExcelField;
import io.github.biezhi.excel.plus.converter.Converter;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @AUTHOR soft
 * @DATE 2019/3/20 10:36
 * @DESCRIBE 用户统计信息
 */
@Data
@Accessors(chain = true)
public class CountInfo {

//    针对老师
    @ExcelField(columnName = "发布课程", order = 1)
    private Long courses;   // 发布的课程数
    @ExcelField(columnName = "上传视频", order = 2)
    private Long tasks;     // 发布的视频资源数
    @ExcelField(columnName = "发布习题", order = 3)
    private Long practice;  // 发布的习题数
    @ExcelField(columnName = "发布试卷", order = 4)
    private Long papers;    // 发布的试卷数
    @ExcelField(columnName = "上传资料", order = 5)
    private Long materials; // 发布的资料数
    @ExcelField(columnName = "问题回复", order = 6)
    private Long askResults;// 问题回复数
    @ExcelField(columnName = "试卷批阅", order = 7)
    private Long paperView; // 试卷批阅数

    //    针对学生
    @ExcelField(columnName = "学习课程", order = 8)
    private Long learns;    // 学习的课程数
    @ExcelField(columnName = "观看视频", order = 9)
    private Long looks;     // 视频数
    @ExcelField(columnName = "已练习题", order = 10)
    private Long doResponse;// 习题练习数
    @ExcelField(columnName = "参与考试", order = 11)
    private Long exams;     // 参加的考试数
    @ExcelField(columnName = "笔记数", order = 12)
    private Long notes;     // 笔记数
    @ExcelField(columnName = "提问数", order = 13)
    private Long asks;      // 提问数
    @ExcelField(columnName = "评价数", order = 14)
    private Long comments;  // 评价数

    @ExcelField(columnName = "用户名", order = 0, convertType =UConverter.class)
    private User user;

    public Student toStudent() {
        return new Student()
                .setLearns(learns)
                .setLooks(looks)
                .setDoResponse(doResponse)
                .setExams(exams)
                .setNotes(notes)
                .setAsks(asks)
                .setComments(comments)
                .setUser(user);
    }

    public static class UConverter implements Converter<User> {

        @Override
        public String write(User value) {
            if (StringKit.isEmpty(value.getName())) {
                return value.getUsername();
            }
            return value.getName();
        }
    }

    @Data
    @Accessors(chain = true)
    public static class Student {
        @ExcelField(columnName = "用户名", order = 0, convertType =UConverter.class)
        private User user;
        @ExcelField(columnName = "学习课程", order = 1)
        private Long learns;    // 学习的课程数
        @ExcelField(columnName = "观看视频", order = 2)
        private Long looks;     // 视频数
        @ExcelField(columnName = "已练习题", order = 3)
        private Long doResponse;// 习题练习数
        @ExcelField(columnName = "参与考试", order = 4)
        private Long exams;     // 参加的考试数
        @ExcelField(columnName = "笔记数", order = 5)
        private Long notes;     // 笔记数
        @ExcelField(columnName = "提问数", order = 6)
        private Long asks;      // 提问数
        @ExcelField(columnName = "评价数", order = 7)
        private Long comments;  // 评价数
    }
}
